package com.pm.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.enums.BusinessType;
import com.pm.business.domain.CompeteEnterpriseHistoryProject;
import com.pm.business.service.ICompeteEnterpriseHistoryProjectService;
import com.pm.common.utils.poi.ExcelUtil;
import com.pm.common.core.page.TableDataInfo;

/**
 * 历史业绩Controller
 * 
 * @author zxl
 * @date 2022-05-07
 */
@RestController
@RequestMapping("/business/compete_enterprise_project")
public class CompeteEnterpriseHistoryProjectController extends BaseController
{
    @Autowired
    private ICompeteEnterpriseHistoryProjectService competeEnterpriseHistoryProjectService;

    /**
     * 查询历史业绩列表
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_project:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompeteEnterpriseHistoryProject competeEnterpriseHistoryProject)
    {
        startPage();
        List<CompeteEnterpriseHistoryProject> list = competeEnterpriseHistoryProjectService.selectCompeteEnterpriseHistoryProjectList(competeEnterpriseHistoryProject);
        return getDataTable(list);
    }

    /**
     * 导出历史业绩列表
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_project:export')")
    @Log(title = "历史业绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompeteEnterpriseHistoryProject competeEnterpriseHistoryProject)
    {
        List<CompeteEnterpriseHistoryProject> list = competeEnterpriseHistoryProjectService.selectCompeteEnterpriseHistoryProjectList(competeEnterpriseHistoryProject);
        ExcelUtil<CompeteEnterpriseHistoryProject> util = new ExcelUtil<CompeteEnterpriseHistoryProject>(CompeteEnterpriseHistoryProject.class);
        util.exportExcel(response, list, "历史业绩数据");
    }

    /**
     * 获取历史业绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_project:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
    {
        return AjaxResult.success(competeEnterpriseHistoryProjectService.selectCompeteEnterpriseHistoryProjectByProjectId(projectId));
    }

    /**
     * 新增历史业绩
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_project:add')")
    @Log(title = "历史业绩", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompeteEnterpriseHistoryProject competeEnterpriseHistoryProject)
    {
        return toAjax(competeEnterpriseHistoryProjectService.insertCompeteEnterpriseHistoryProject(competeEnterpriseHistoryProject));
    }

    /**
     * 修改历史业绩
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_project:edit')")
    @Log(title = "历史业绩", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompeteEnterpriseHistoryProject competeEnterpriseHistoryProject)
    {
        return toAjax(competeEnterpriseHistoryProjectService.updateCompeteEnterpriseHistoryProject(competeEnterpriseHistoryProject));
    }

    /**
     * 删除历史业绩
     */
    @PreAuthorize("@ss.hasPermi('business:compete_enterprise_project:remove')")
    @Log(title = "历史业绩", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable Long[] projectIds)
    {
        return toAjax(competeEnterpriseHistoryProjectService.deleteCompeteEnterpriseHistoryProjectByProjectIds(projectIds));
    }
}
